<template>
  <div>
    <div class="kflexc" style=" padding:20px 20px 0px;">

      <el-select clearable v-model="search.type"  style="width: 250px; margin-bottom: 20px;" filterable placeholder="选择下载类型">
        <el-option  label="全部" value="0"></el-option>
        <el-option  label="时间" value="1"></el-option>
        <el-option  label="商品" value="2"></el-option>
        <el-option  label="销售渠道 我的" value="3"></el-option>
        <el-option  label="销售渠道 分销商" value="4"></el-option>
      </el-select>

      <el-button type="danger" style=" margin-bottom: 20px;" @click="sousuo()">搜索</el-button>
    </div>
    <div style="margin:0 20px 20px;" v-loading="loading">
      <el-table :data="list" border style="width: 100%; " ref="multipleTable">
        <el-table-column align='center' prop='created_at' label="日期"></el-table-column>
        <el-table-column align='center' prop='status_name' label="状态"></el-table-column>
        <el-table-column align='center' label="操作">
          <template slot-scope="scope">
            <el-button type="text"  @click="daochu(scope.row)" v-if="scope.row.status == 20">下载</el-button>
            <div v-if="scope.row.status == 30">导出失败，联系技术</div>
          </template>
        </el-table-column>
      </el-table>
     <el-pagination style="text-align: right; margin: 20px;" background layout="total,prev, pager, next" :current-page="search.page"
        @current-change="fanye" :page-size="search.page_size" :total="total"></el-pagination>
    </div>
  </div>
</template>

<script>
  import axios from 'axios'
  export default {
    name: "yongjin",
    data() {
      return {
        list:[],
        loading:true,
        search:{
          page:1,
          page_size:20,
          type:this.$route.query.type || '0'
        },
        total:0
      }
    },
    created() {
      this.getlist()

    },
    mounted() {

    },
    methods: {
      fanye:function(val){
        this.search.page = val
        this.getlist()
      },
      daochu:function(item){
        location.href = item.result_file
      },
      sousuo:function(){
        this.search.page = 1
        this.getlist()
      },
      //获取列表
      getlist: function() {
        this.loading = true
        axios.get('/api/plan-market/order/income/log/list',{params:this.search})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.list = response.data.data.data
              this.total = response.data.data.total
              this.loading = false
            } else {
              this.loading = false
              this.$message.error(response.data.msg.info);
            }
          })
      }
    }
  }
</script>


<style lang="scss" scoped>
  @import "@/assets/zuixin.scss";

  .lia {
    font-size: 16px;
  }
</style>
